package com.example.demo.service;

import com.example.demo.entity.Articleinfo;
import com.example.demo.entity.Comment;
import com.example.demo.mapper.ArticleMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ArticleService {

    @Resource
    private ArticleMapper articleMapper;

    public int getArtCountByUid(Integer uid){
        return articleMapper.getArtCountByUid(uid);
    }

    public List<Articleinfo> getMyList(Integer uid) {
        return articleMapper.getMyList(uid);
    }

    public List<Comment> comments(Integer blog_id){
        return articleMapper.comments(blog_id);
    }

    public int del(Integer id,Integer uid){
        return articleMapper.del(id,uid);
    }

    public Articleinfo getDetail(Integer id){
        return articleMapper.getDetail(id);
    }

    public int incrRCount(Integer id){
        return articleMapper.incrRCount(id);
    }

    public int add(Articleinfo articleinfo){
        return articleMapper.add(articleinfo);
    }

    public int draft(Articleinfo articleinfo) {
        return articleMapper.draft(articleinfo);
    }

    public int update(Articleinfo articleinfo){
        return articleMapper.update(articleinfo);
    }

    public int updateState(Integer id){
        return articleMapper.updateState(id);
    }

    public List<Articleinfo> getListByPage(Integer psize,Integer offsize){
        return articleMapper.getListByPage(psize,offsize);
    }

    public int addcomment(String username, String contents, Integer blog_id){
        return articleMapper.addComment(username,contents,blog_id);
    }

    public void addUpvote(Integer blog_id){
        articleMapper.addUpvote(blog_id);
    }
    public int getCount(){
        return articleMapper.getCount();
    }
}
